import Bullet from "./bullet";

import RoleSelectScene from "../scene/RoleSelectScene";
import Sprite from "../base/Sprite";

//logo图片
const log_name = new Image();
log_name.src = "images/logo.png";

const pressx = new Image();
pressx.src = "images/pressx.png";

export default class Start {
  constructor(ctx) {
    this.log_name = log_name;
    this.pressx = pressx;
    this.ctx = ctx;
  }

  // 绘制到画布
  drawToCanvas(ctx) {
    //ctx.drawImage(this.pressx, 38, 400, 240, 80);
    //ctx.drawImage(this.log_name, 38, 466, 240, 100);
    this.img_logo = Sprite.getImage("logo");
    this.imglogo = new Sprite(this.img_logo, 38, 400, 240, 80);
    this.imglogo.draw(this.ctx);

    this.img_pressx = Sprite.getImage("pressx");
    this.imgpressx = new Sprite(this.img_pressx, 38, 466, 240, 100);
    this.imgpressx.draw(this.ctx);
    this.bindEvent();
  }

  bindEvent() {
    let _this = this;

    wx.onTouchStart(e => {
      let x = e.touches[0].clientX,
        y = e.touches[0].clientY;
      console.log("start--------------------------1");
      //this.RoleSelectScene = new RoleSelectScene(this.ctx);
      if (
        x >= _this.imgpressx.x &&
        x <= _this.imgpressx.x + _this.imgpressx.width &&
        y >= _this.imgpressx.y &&
        y <= _this.imgpressx.y + _this.imgpressx.height
      ) {
        console.log("start--------------------------2");
        //点击开始按钮，进入角色选择页面
        this.RoleSelectScene = new RoleSelectScene(this.ctx);
        return;
      }
    });
  }
}
